package com.future.hedongjun.mine.bean.response;

import com.future.baselib.entity.BaseResponse;
import com.future.hedongjun.mall.bean.CouponBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jniu
 * @Email niuxiaoqi@hztianque.com
 * @time 2018/12/5
 */
public class CouponListResponse extends BaseResponse {

    public List<CouponBean> data;

    @Override
    public void parseInfo(String content) throws JSONException {
        JSONArray array = new JSONArray(content);
        data = new ArrayList<>();
        for (int i = 0; i < array.length(); i++) {
            JSONObject object = array.optJSONObject(i);
            CouponBean bean = new CouponBean();
            bean.id = object.optString("discount_id");
            bean.outOfDateTime = object.optString("end_time");
            bean.usePrice = object.optDouble("use_price",0);
            bean.couponPrice = object.optDouble("amount",0);
            data.add(bean);
        }
    }
}
